---
title: 'List Keys'
description: 'List API keys'
---

Pass the optional and required parameters as per the official [API docs](https://unkey.com/docs/api-reference/apis/list-keys). See the DTO reference below for more information.

```java
package com.example.myapp;

import com.unkey.unkeysdk.dto.GetAPIResponse;

@RestController
public class APIController {

    private static IAPIService apiService = new APIService();

    @GetMapping("/keys")
    public ListKeysResponse listKeys(
            @RequestParam String apiId,
            @RequestBody(required = false) ListKeysRequest listKeyRquest,
            @RequestHeader("Authorization") String authToken) {
        // Delegate the creation of the key to the IAPIService from the SDK
        return iapiService.listKeys(listKeyRquest, apiId, authToken);
    }
}

```

### DTOs Reference

The DTOs used in the code for a better understanding of request and response bodies.

#### Request

```java
public class ListKeysRequest {
    private String apiId;
    private Integer limit;
    private Integer offset;
    private String ownerId;
}
```

#### Response

```java
public class ListKeysResponse {
    private List<KeyAttributes> keys;
    private Integer total;
}
```

```java
public class KeyAttributes {
    private String id;
    private String apiId;
    private String workspaceId;
    private String start;
    private String name;
    private String ownerId;
    private Meta meta;
    private Long createdAt;
    private Long expires;
    private Integer remaining;
    private KeyRateLimit ratelimit;
}
```
